%from helper import PrettyDate, Url
<!DOCTYPE html>
<!--[if IEMobile 7 ]><html class="no-js iem7"><![endif]-->
<!--[if lt IE 9]><html class="no-js lte-ie8"><![endif]-->
<!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
<head>
  <meta charset="utf-8">
  <title>Duke's Blog</title>
  <meta name="author" content="Duke Fong">

  <meta name="description" content="Duke's Blog &hellip;">

  <!-- http://t.co/dKP3o1e -->
  <meta name="HandheldFriendly" content="True">
  <meta name="MobileOptimized" content="320">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <link rel="canonical" href="http://blog.dukelec.com">
  <link href="/static/img/favicon.png" rel="icon">
  <link href="/static/css/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
  <script src="/static/js/jquery-1.8.3.js"></script>
  <script src="/static/js/jquery.cookie.js"></script>

  <link rel="stylesheet" type="text/css" href="/static/markitup/skins/markitup/style.css">
  <script type="text/javascript" src="/static/markitup/jquery.markitup.js"></script>
  <link rel="stylesheet" type="text/css" href="/static/markitup/sets/html/style.css">
  <script type="text/javascript" src="/static/markitup/sets/html/set.js"></script>

  <script type="text/javascript" src="/static/syntaxhighlighter/js/shCore.js"></script>
  <script type="text/javascript" src="/static/syntaxhighlighter/js/shAutoloader.js"></script>
  <link type="text/css" rel="stylesheet" href="/static/syntaxhighlighter/css/shCoreDefault.css"/>

  <script type="text/javascript" src="/static/farbtastic/farbtastic.js"></script>
  <link rel="stylesheet" href="/static/farbtastic/farbtastic.css" type="text/css" />

  <link href="/atom.xml" rel="alternate" title="Duke Blog" type="application/atom+xml">
  <!--Fonts from Google's Web font directory at http://google.com/webfonts -->
<link href='/static/css/fonts-serif.css' rel='stylesheet' type='text/css'>
<link href='/static/css/fonts-sans.css' rel='stylesheet' type='text/css'>

</head>

<body>

<header role="banner">
  <hgroup>
    <h1><a href="/">Duke's Blog</a></h1>
    <h2>my home is not of this world...</h2>
  </hgroup>
</header>

<nav role="navigation">
  <ul class="subscription" data-subscription="rss">
    <li><a href="/atom.xml" rel="subscribe-rss" title="subscribe via RSS">RSS</a></li>
  </ul>

  <form action="http://google.com/search" method="get">
    <fieldset role="search">
      <input type="hidden" name="q" value="http://blog.dukelec.com" />
      <input class="search" type="text" name="q" results="0" placeholder="Search"/>
    </fieldset>
  </form>

  <ul role=main-navigation>
    <li><a href="/">Home</a></li>
    <li><a href="/tag/about">About</a></li>
  </ul>
</nav>

<div id="main"> <!--main start-->
<div id="content"> <!--content start-->
<div class="blog-index"> <!--blog-index start-->
<!--layout_main include start-->
%include
<!--layout_main include stop-->

</div> <!--blog-index stop-->

<style type="text/css">
.sidebar a{text-decoration:none}
</style>

<aside class="sidebar">
  <section>
    <h1>Purview</h1>
    <ul>
%if sidebar['account']:
%from google.appengine.api import users
      <li>Hi {{sidebar['account'].nickname}}, welcome to my blog,
        you can <a href="/account?continue={{Url()}}">change your nick name</a>,
        or <a href="{{users.create_logout_url(Url())}}">logout.</a>
      </li>
      <li>
<!--purview select end-->
filter by purview:
<select id="purview">
  <option value="">All</option>
  %for i in sidebar['account'].purviews:
  <option value="{{i}}">{{i}}</option>
  %end
</select>
<script>
$("#purview").val($.cookie("purview"));
$("#purview").change(function () {
  $.cookie("purview", $("#purview option:selected").val(), {expires:7, path:"/"});
  location.reload();
});
</script>
<!--purview select end-->
      </li>
%else:
      <li>
<!--direct login start-->
Login with:<br/>
<a id="google" href="/login?openid=https://www.google.com/accounts/o8/id&continue={{Url()}}"><img src="/static/img/googleW.png"/></a>
<a id="yahoo" href="/login?openid=yahoo.com&continue={{Url()}}"><img src="/static/img/yahooW.png"/></a>
<a id="myspace" href="/login?openid=myspace.com&continue={{Url()}}"><img src="/static/img/myspaceW.png"/></a>
<a id="aol" href="/login?openid=aol.com&continue={{Url()}}"><img src="/static/img/aolW.png"/></a>
<a id="myopenid" href="/login?openid=myopenid.com&continue={{Url()}}"><img src="/static/img/myopenidW.png"/></a>
<a id="more" href="/login"> - see more -</a><br/>
after login, you may be able to view more hidden posts.
<!--direct login end-->
      </li>
%end
      <li>
<!--language select end-->
filter by language:
<select id="language">
  <option value="">All</option>
  <option value="cantonese">Cantonese</option>
  <option value="english">English</option>
  <option value="mandarin">Mandarin</option>
</select>
<script>
$("#language").val($.cookie("language"));
$("#language").change(function () {
  $.cookie("language", $("#language option:selected").val(), {expires:7, path:"/"});
  location.replace("/");
});
</script>
<!--language select end-->
      </li>
    </ul>
  </section>

  <section>
    <h1>Categories</h1>
    <ul id="categorie_list">
%for i in sidebar['categories']:
  %if i[1][0] == i[1][1]:
      <li><a href="/category/{{i[0]}}">{{i[0]}}({{i[1][1]}})</a></li>
  %else:
      <li><a {{!' href="/category/%s"'%i[0] if i[1][1] != 0 else ''}}>{{i[0]}}({{i[1][1]}}/{{i[1][0]}})</a></li>
  %end
%end
    </ul>
  </section>

  <section>
    <h1>Recent Comments</h1>
    <ul id="recent_comments">
%for i in sidebar['recent_comments_key']:
      <li><a href="/id/{{i.parent().id()}}">{{PrettyDate(i.id())}} &bull; {{i.get().author_key.get().nickname}}:</a>
          {{i.get().body[:20]}}</li>
%end
    </ul>
  </section>

  <section>
    <h1>Popular Threads</h1>
    <ul id="popular_threads">
%for i in sidebar['popular_posts']:
      <li><a href="/id/{{i.key.id()}}">{{i.counter}} hits &bull; {{i.title}}</a></li>
%end
    </ul>
  </section>

  <section>
    <h1>Tags</h1>
    <ul id="tag_list">
%for i in sidebar['tags']:
  %if i[1][0] == i[1][1]:
      <a href="/tag/{{i[0]}}">{{i[0]}}({{i[1][1]}})</a>
  %else:
      <a {{!' href="/tag/%s"'%i[0] if i[1][1] != 0 else ''}}>{{i[0]}}({{i[1][1]}}/{{i[1][0]}})</a>
  %end
%end
    </ul>
  </section>
</aside>
</div> <!--content end-->
</div> <!--main end-->

<footer role="contentinfo">
  <p>
    Copyright &copy; 2012 - Duke Fong -
    <span class="credit">Powered by <a href="https://appengine.google.com">GAE</a></span>
  </p>
</footer>

</body>
<script type="text/javascript">
/* sidebar toggle */
$(document).ready(function() {
function addSidebarToggler() {
  if(!$('body').hasClass('sidebar-footer')) {
    $('#content').append('<span class="toggle-sidebar"></span>');
    $('.toggle-sidebar').bind('click', function(e) {
      e.preventDefault();
      if ($('body').hasClass('collapse-sidebar')) {
        $('body').removeClass('collapse-sidebar');
      } else {
        $('body').addClass('collapse-sidebar');
      }
    });
  }
/*
  var sections = $('aside.sidebar > section');
  if (sections.length > 1) {
    sections.each(function(section, index){
      if ((sections.length >= 3) && index % 3 === 0) {
        $(section).addClass("first");
      }
      var count = ((index +1) % 2) ? "odd" : "even";
      $(section).addClass(count);
    });
  }
  if (sections.length >= 3){ $('aside.sidebar').addClass('thirds'); }
*/
}
addSidebarToggler()
});

/* SyntaxHighlighter */
function path()
{
  var args = arguments,
      result = []
      ;
       
  for(var i = 0; i < args.length; i++)
      result.push(args[i].replace('@', '/static/syntaxhighlighter/js/'));
       
  return result
};
 
SyntaxHighlighter.autoloader.apply(null, path(
  'applescript            @shBrushAppleScript.js',
  'actionscript3 as3      @shBrushAS3.js',
  'bash shell             @shBrushBash.js',
  'coldfusion cf          @shBrushColdFusion.js',
  'cpp c                  @shBrushCpp.js',
  'c# c-sharp csharp      @shBrushCSharp.js',
  'css                    @shBrushCss.js',
  'delphi pascal          @shBrushDelphi.js',
  'diff patch pas         @shBrushDiff.js',
  'erl erlang             @shBrushErlang.js',
  'groovy                 @shBrushGroovy.js',
  'java                   @shBrushJava.js',
  'jfx javafx             @shBrushJavaFX.js',
  'js javascript          @shBrushJScript.js',
  'perl pl                @shBrushPerl.js',
  'php                    @shBrushPhp.js',
  'text plain             @shBrushPlain.js',
  'py python              @shBrushPython.js',
  'ruby rails             @shBrushRuby.js',
  'sass scss              @shBrushSass.js',
  'scala                  @shBrushScala.js',
  'sql                    @shBrushSql.js',
  'vb vbnet               @shBrushVb.js',
  'xml xhtml xslt html    @shBrushXml.js'
));
SyntaxHighlighter.all();

/* google analysis */
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-38012736-1']);
_gaq.push(['_setDomainName', 'dukelec.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = 'http://stats.g.doubleclick.net/dc.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</html>
